import matplotlib.pyplot as plt
import numpy as np

# Data
activation_functions = ['ELU', 'SELU', 'ReLU', 'GELU']
mnist_accuracy = [98.0, 98.3, 98.1, 97.9]
cifar10_accuracy = [48.0, 52.8, 48.1, 46.1]

# Set the width and position of the bars
bar_width = 0.35
x = np.arange(len(activation_functions))

# Define soft colors for the bars
mnist_color = '#FFB74D'  # Soft Orange
cifar10_color = '#A191E0'  # Soft Purple

# Draw grouped bar chart
fig, ax = plt.subplots(figsize=(10, 6))

bars1 = ax.bar(x - bar_width/2, mnist_accuracy, bar_width, label='MNIST', color=mnist_color)
bars2 = ax.bar(x + bar_width/2, cifar10_accuracy, bar_width, label='CIFAR-10', color=cifar10_color)

# Add labels and title
ax.set_xlabel('Activation Function', fontsize=14)
ax.set_ylabel('Accuracy (%)', fontsize=14)
ax.set_title('Accuracy of Different Activation Functions on MNIST and CIFAR-10 Datasets', fontsize=16)
ax.set_xticks(x)
ax.set_xticklabels(activation_functions, fontsize=12)
ax.legend(fontsize=12)

# Adjust y-axis limits and grid
plt.ylim(0, 100)
ax.yaxis.grid(color='grey', linestyle='--', linewidth=0.7, alpha=0.5)

# Show the bar chart
plt.tight_layout()
plt.savefig('activation', bbox_inches='tight', dpi=300)
